package com.educationx;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;

public class LectureActivity extends Activity {
	private TextView textviewlecturetitle;
	private WebView webviewlecture;
	private ListView listcomments;
	private List<Comment> comments;
	private EditText  edittextcomment;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_lecture);

		String title = getIntent().getStringExtra("title");
		String link = getIntent().getStringExtra("link").trim();
		
		comments = new ArrayList<Comment>();

		textviewlecturetitle = (TextView) findViewById(R.id.textViewLectureTitle);
		webviewlecture = (WebView) findViewById(R.id.webViewLecture);
		edittextcomment = (EditText) findViewById(R.id.editTextComment);
		listcomments = (ListView) findViewById(android.R.id.list);

		textviewlecturetitle.setText(title);

		webviewlecture. getSettings().setJavaScriptEnabled (true);
		webviewlecture. getSettings().setJavaScriptCanOpenWindowsAutomatically (false);
		webviewlecture. getSettings().setPluginsEnabled (true);
		webviewlecture. getSettings().setSupportMultipleWindows (false);
		webviewlecture. getSettings().setSupportZoom (false);
		webviewlecture. setVerticalScrollBarEnabled (false);
		webviewlecture. setHorizontalScrollBarEnabled (false);

		webviewlecture.loadUrl(link);
	}
	
	public void updateCommentList(View view) {
		comments.add(new Comment(edittextcomment.getText().toString(), "date", "username"));
		CommentListArrayAdapter listAdapter = new CommentListArrayAdapter(LectureActivity.this, R.layout.row_comment, comments);
		listcomments.setAdapter(listAdapter);
	}

}
